using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace WindowsApplication4
{
    public partial class AddAttack : Form
    {

        public AddAttack(Village vill)
        {
            InitializeComponent();

            villageLookup1.SelectedVillageChangeFoundEvent += new VillageLookup.SelectedVillageChangeDelegate(villageLookup1_SelectedVillageChangeFoundEvent);
            villageLookup1.lblTitle.Text = "Select the village you will be attacking from";
            villageLookup1.SelectedVillage = vill;

            foreach (Unit unit in Worlds.currentWorld.Units.Values)
            {
                cbUnit.Items.Add(unit);
            }
            cbUnit.SelectedIndex = 0;
        }

        public AddAttack()
        {
            InitializeComponent();

            villageLookup1.SelectedVillageChangeFoundEvent += new VillageLookup.SelectedVillageChangeDelegate(villageLookup1_SelectedVillageChangeFoundEvent);
            villageLookup1.lblTitle.Text = "Select the village you will be attacking from";


            foreach (Unit unit in Worlds.currentWorld.Units.Values)
            {
                cbUnit.Items.Add(unit);
            }
            cbUnit.SelectedIndex = 0;
        }
        public Village selectedVillage = null;

        void villageLookup1_SelectedVillageChangeFoundEvent(Village vil)
        {
            selectedVillage = vil;

            EnableDisableButtons();

        }

        private void EnableDisableButtons() {

            if (selectedVillage != null & cbUnit.SelectedItem != null)
            {
                btnAddAttack.Enabled = true;
            }
            else
            {
                btnAddAttack.Enabled = false;
            }

        }

        private void btnAddAttack_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
            this.Close();

        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();

        }

        private void AddAttack_Load(object sender, EventArgs e)
        {

        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {
            Help.AttackPriority();
        }

        private void cbUnit_SelectedIndexChanged(object sender, EventArgs e)
        {
            EnableDisableButtons();
        }
    }
}